package Servlets;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.mail.iap.Response;

import DB.DAOManager;

public class UpdateFee extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException{
	doPost(req,res);
}
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException{
	
	String newval=req.getParameter("newfee");
	System.out.println(newval);
	DAOManager dao;
	try {
		dao = new DAOManager();
		Connection conn=dao.getConnection();
		PreparedStatement pstmt=conn.prepareStatement("insert into TransactionFee(TransactionFeeValue) values(?)");
		pstmt.setString(1, newval);
		
		
		if(pstmt.executeUpdate()>0){
			System.out.println("DSJHFKJHKJRSDFDSKFKDSFKJDSA");
			/*res.sendRedirect("addtransactionfee.jsp?msg=ok");*/
		res.sendRedirect("admin_index.jsp?msg=ok");
		}
		else{
		/*res.sendRedirect("addtransactionfee.jsp?msg=no");*/
		res.sendRedirect("admin_index.jsp?msg=no");
		}
	} catch (ClassNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}
}
